<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>短信模板查看</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet" type="text/css">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>

    <script>
        layui.use(['form', 'jquery', 'element', 'laydate', 'layer'], function () {
            var form = layui.form;
            var $ = layui.$;
            var laydate = layui.laydate;
            var layer = layui.layer;
            var mgrId = getUrlParam("mgrId");
            laydate.render({
                elem: '#startTime'
            });
            laydate.render({
                elem: '#endTime'
            });
            laydate.render({
                elem: '#thresholdStartTime'
            });
            laydate.render({
                elem: '#thresholdEndTime'

            });
            laydate.render({
                elem: '#everyDayStartTime'
                , type: 'time'
                , btns: ['clear', 'confirm']
            });
            laydate.render({
                elem: '#everyDayEndTime'
                , type: 'time'
                , btns: ['clear', 'confirm']
            });
            //页面数据初始化
            $(document).ready(function () {
                var url = '/template/findTemplate';
                var param = {
                    mgrId: mgrId
                };
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        console.info(data);
                        $("#everyDayStartTime").val(data.everyDayStartTime);
                        $("#everyDayEndTime").val(data.everyDayEndTime);
                        $("#cycleThreshold").val(data.cycleThreshold);
                        $("#threshold").val(data.threshold);
                        $("#startTime").val(data.startDate);
                        $("#endTime").val(data.endDate);

                        if (data.realTime == 0) {
                            $("#realTime").val("立即发送");
                        }
                        else{
                            $("#realTime").val("延时"+data.realTime+"分钟");
                        }

                        if (data.isLocal == 0) {
                            $("#isLocal").val("本地发送");
                            $("#localDate").val(data.localDate);
                            $("#province").hide();
                        } else if (data.isLocal == 1) {
                            $("#isLocal").val("本地不发送");
                            $("#localTime").hide();
                            if(data.isProvince == 0){$("#isProvince").val("省内发送");}
                            else{$("#isProvince").val("省内+省外");}
                        }else if(data.isLocal==2){
                            $("#isLocal").val("本地+外地");
                            $("#localDate").val(data.localDate);
                            if(data.isProvince == 0){$("#isProvince").val("省内发送");}
                            else{$("#isProvince").val("省内+省外");}
                        }
                        var cycleMsg;
                        if (data.isThreshold == 0) {
                            cycleMsg = "没有设置阀值";
                        } else if (data.isThreshold == 1) {
                            cycleMsg = "发送总量为" + data.threshold + "条";
                        } else if (data.isThreshold == 2) {
                            if (data.cycle == 1) {
                                cycleMsg = "发送量为每年" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 2) {
                                cycleMsg = "发送量为每月" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 3) {
                                cycleMsg = "发送量为每周" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 4) {
                                cycleMsg = "发送量为每日" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 5) {
                                cycleMsg = "发送量为" + data.cycleThreshold + "条,时间范围:" +
                                    data.thresholdStartTime + "至" + data.thresholdEndTime;
                            }
                        } else if (data.isThreshold ==3) {
                            if (data.cycle == 1) {
                                cycleMsg ="发送总量为" + data.threshold + "条,周期发送量为每年" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 2) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每月" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 3) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每周" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 4) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为每日" + data.cycleThreshold + "条";
                            }
                            if (data.cycle == 5) {
                                cycleMsg = "发送总量为" + data.threshold + "条,周期发送量为" + data.cycleThreshold + "条,时间范围:" +
                                    data.thresholdStartTime + "至" + data.thresholdEndTime;
                            }
                        }
                        $("#threshold").text(cycleMsg);
                    }
                    ,
                    error: function (data) {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });
        });
    </script>
</head>
<body>
<!--nav-->
<div class="layui-html-limit">
    <!--container-->
    <div class="layui-content-body">
        <div class="scroll-box">
            <div class="breadcrumb-box">
              <span class="layui-breadcrumb" lay-separator="|">
    <a href="javascript:returnIndex2()">首页&nbsp;</a>
  <a href=""> &nbsp;短信模板管理&nbsp; </a>
  <a href="smsTemplateManage.html"> &nbsp;短信项目模板配置管理</a>
  <a href=""> &nbsp;短信项目模板查看&nbsp; </a>
</span>
            </div>
            <div class="content-box">
                <div class="layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label" style="width: auto">发送起止时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="startTime" autocomplete="off" class="layui-input"
                                       disabled  >
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="endTime" autocomplete="off" class="layui-input" disabled>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label" style="width:auto">每日发送时间段</label>
                            <div class="layui-input-inline">
                                <div class="layui-input-inline">
                                    <input type="text" name="date" id="everyDayStartTime" autocomplete="off"
                                           class="layui-input"
                                           disabled>
                                </div>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <div class="layui-input-inline">
                                    <input type="text" name="date" id="everyDayEndTime" autocomplete="off"
                                           class="layui-input"
                                           disabled>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label">发送实时性</label>
                            <div class="layui-input-block">
                                <input type="text"   style="width:auto"
                                      id="realTime" autocomplete="off" class="layui-input" disabled>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label" style="width: auto">本地号码发送</label>
                            <div class="layui-input-block">
                                <input type="text" id="isLocal"
                                       autocomplete="off" class="layui-input" disabled  style="width:auto">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" id="localTime">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label" style="width: auto">本地发送保存时间</label>
                            <div class="layui-input-block">
                                <input type="text" id="localDate"
                                       autocomplete="off" class="layui-input" disabled style="width:auto">
                            </div>
                        </div>
                    </div>
						<div class="layui-form-item" id="province">
							<div class="layui-block" pane="">
								<label class="layui-form-label" style="width: auto">外地发送范围</label>
								<div class="layui-input-block">
									<input type="text" id="isProvince" autocomplete="off"
										class="layui-input" disabled style="width:auto">
								</div>
							</div>
						</div>
						<div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label" style="width: auto">短信发送阀值</label>
                            <div class="layui-input-block">
                                <!--<input type="text" id="threshold"-->
                                       <!--autocomplete="off" class="layui-input" disabled  style="width:auto">-->
                                <div id="threshold" class="text-autoWidth"></div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <a href="smsTemplateManage.html"><button class="layui-btn">返回</button></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>